<?php
include '../../auth/ceklogin.php';
include '../../sql/conn.php';
$user=$_SESSION['userbkknt'];

#data parsingan
$no_wo="INV/II/06/2010";
 
#sertakan library FPDF dan bentuk objek
require('fpdf/fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->AliasNbPages();

#tampilkan judul laporan
$judul = "WORK ORDER";
$pdf->SetFont('Times','BU','16');
$pdf->Cell(0,5, $judul, '0', 1, 'C');

#tampilkan no WO
$pdf->SetFont('Times','','16');
$pdf->Cell(0,8, 'No : '.$no_wo, '0', 1, 'C');
$pdf->Ln('20');

#setting tebal garis cell dan lebar cell
$pdf->SetLineWidth(0.5);
$cell=array(30,75,15,70); // hasil jumlahnya harus selalu 190

#tampilkan Date
$pdf->SetFont('Arial','','10');
$pdf->Cell($cell[0],5, 'Date', 'LT', 0, '');
$pdf->Cell($cell[1],5, ': '.date("d/m/Y"), 'RT', 0, '');

#tampilkan Job Status
$pdf->SetFont('Arial','B','11');
$pdf->Cell(85,5, 'Job Status', '1', 0, 'C');
$pdf->Ln();

#tampilkan customer
$custome='Ayana Resort & SPA';
$pdf->SetFont('Arial','','10');
$pdf->Cell($cell[0],5, 'Customer', 'L', 0, '');
$pdf->Cell($cell[1],5, ': '.$custome, 'R', 0, '');
	$pdf->Cell(9.444,5, '', '', 0, 'C');
	$pdf->Cell(9.444,5, '', '', 0, 'C');
	$pdf->Cell(9.444,5, '', 'R', 0, 'C');
	$pdf->Cell(9.444,5, '', '', 0, 'C');
	$pdf->Cell(9.444,5, '', '', 0, 'C');
	$pdf->Cell(9.444,5, '', 'R', 0, 'C');
	$pdf->Cell(9.444,5, '', '', 0, 'C');
	$pdf->Cell(9.444,5, '', '', 0, 'C');
	$pdf->Cell(9.444,5, '', 'R', 0, 'C');
$pdf->Ln();

#tampilkan address
$address='Jl. karangasem Jimbaran Bali';
$pdf->SetFont('Arial','','10');
$pdf->Cell($cell[0],5, 'Address', 'L', 0, '');
$pdf->Cell($cell[1],5, ': '.$address, 'R', 0, '');

#tampilkan kode job status => H = Hold ; D = Done ; P = Pending
$jobstatus='D';
$pdf->SetFillColor(0,0,0);
$pdf->SetFont('Times','B','12');
if($jobstatus=='H'){
	$pdf->Cell(9.444,5, '', 'L', 0, 'C');
	$pdf->SetTextColor(255,255,255);
	$pdf->Cell(9.444,5, 'H', '', 0, 'C',true);
	$pdf->SetTextColor(0,0,0);
	$pdf->Cell(9.444,5, '', 'R', 0, 'C');
	$pdf->Cell(9.444,5, '', 'L', 0, 'C');
	$pdf->Cell(9.444,5, 'D', '', 0, 'C');
	$pdf->Cell(9.444,5, '', 'R', 0, 'C');
	$pdf->Cell(9.444,5, '', 'L', 0, 'C');
	$pdf->Cell(9.444,5, 'P', '', 0, 'C');
	$pdf->Cell(9.444,5, '', 'R', 0, 'C');
}
elseif($jobstatus=='D'){
	$pdf->Cell(9.444,5, '', 'L', 0, 'C');
	$pdf->Cell(9.444,5, 'H', '', 0, 'C');
	$pdf->Cell(9.444,5, '', 'R', 0, 'C');
	$pdf->Cell(9.444,5, '', 'L', 0, 'C');
	$pdf->SetTextColor(255,255,255);
	$pdf->Cell(9.444,5, 'D', '', 0, 'C',true);
	$pdf->SetTextColor(0,0,0);
	$pdf->Cell(9.444,5, '', 'R', 0, 'C');
	$pdf->Cell(9.444,5, '', 'L', 0, 'C');
	$pdf->Cell(9.444,5, 'P', '', 0, 'C');
	$pdf->Cell(9.444,5, '', 'R', 0, 'C');
}
elseif($jobstatus=='P'){
	$pdf->Cell(9.444,5, '', 'L', 0, 'C');
	$pdf->Cell(9.444,5, 'H', '', 0, 'C');
	$pdf->Cell(9.444,5, '', 'R', 0, 'C');
	$pdf->Cell(9.444,5, '', 'L', 0, 'C');
	$pdf->Cell(9.444,5, 'D', '', 0, 'C');
	$pdf->Cell(9.444,5, '', 'R', 0, 'C');
	$pdf->Cell(9.444,5, '', 'L', 0, 'C');
	$pdf->SetTextColor(255,255,255);
	$pdf->Cell(9.444,5, 'P', '', 0, 'C',true);
	$pdf->SetTextColor(0,0,0);
	$pdf->Cell(9.444,5, '', 'R', 0, 'C');
}
else{
	$pdf->Cell(9.444,5, '', 'L', 0, 'C');
	$pdf->Cell(9.444,5, 'H', '', 0, 'C');
	$pdf->Cell(9.444,5, '', 'R', 0, 'C');
	$pdf->Cell(9.444,5, '', 'L', 0, 'C');
	$pdf->Cell(9.444,5, 'D', '', 0, 'C');
	$pdf->Cell(9.444,5, '', 'R', 0, 'C');
	$pdf->Cell(9.444,5, '', 'L', 0, 'C');
	$pdf->Cell(9.444,5, 'P', '', 0, 'C');
	$pdf->Cell(9.444,5, '', 'R', 0, 'C');
}
$pdf->Ln();

#tampilkan Contact Person
$contactp='Bpk. Mujianto';
$pdf->SetFont('Arial','','10');
$pdf->Cell($cell[0],5, 'Contact Person', 'L', 0, '');
$pdf->Cell($cell[1],5, ': '.$contactp, 'R', 0, '');

#tampilkan kode pegawai
$pdf->SetFont('Arial','B','11');
	$pdf->Cell(9.444,5, '', '', 0, 'C');
	$pdf->Cell(9.444,5, '', '', 0, 'C');
	$pdf->Cell(9.444,5, '', 'R', 0, 'C');
	$pdf->Cell(9.444,5, '', '', 0, 'C');
	$pdf->Cell(9.444,5, '', '', 0, 'C');
	$pdf->Cell(9.444,5, '', 'R', 0, 'C');
	$pdf->Cell(9.444,5, '', '', 0, 'C');
	$pdf->Cell(9.444,5, '', '', 0, 'C');
	$pdf->Cell(9.444,5, '', 'R', 0, 'C');
$pdf->Ln();

#tampilkan Telp. No.
$telpno='031 - 399292';
$pdf->SetFont('Arial','','10');
$pdf->Cell($cell[0],5, 'Telp. No.', 'L', 0, '');
$pdf->Cell($cell[1],5, ': '.$telpno, 'R', 0, '');

#tampilkan Requested Date
$requestedDate='21/06/2010';
$pdf->SetFont('Times','I','12');
$pdf->Cell(85,5, 'Requested Date : ', 'RT', 0, '');
$pdf->SetFont('Arial','','10');
$pdf->Ln();

#buat ruang kosong lanjutan dari requested date
$pdf->Cell($cell[0],15, '', 'LB', 0, '');
$pdf->Cell($cell[1],15, '', 'RB', 0, '');
$pdf->Cell($cell[2],15, '', 'LB', 0, '');
$pdf->SetFont('Times','I','12');
$pdf->Cell($cell[3],15, '21/06/2010 - 21/06/2010', 'RB', 0, '');
$pdf->SetFont('Arial','','10');
$pdf->Ln();

#Unit Type, M/N, dan S/N
$unittype='Air cooled chiller';
$m_n='';
$s_n='';
$pdf->SetFont('Arial','B','11');
$pdf->Cell(63.3333,8, 'Unit Type : '.$unittype, '1', 0, '');
$pdf->Cell(63.3333,8, 'M/N : '.$m_n, '1', 0, '');
$pdf->Cell(63.3333,8, 'S/N : '.$s_n, '1', 0, '');
$pdf->Ln();

#scope of work
$pdf->SetFont('Times','BUI','11');
$pdf->Cell(0,5, 'Scope of work:', 'LTR', 1, '');

$query="select scope_of_work from wo where id_wo='$idwo'";
$sql = mysql_query ($query);
$scopeofwork=mysql_fetch_array($sql);
$scopeofwork=explode("-",$scopeofwork[0]);

$pdf->SetFont('Times','BI','11');
foreach($scopeofwork as $ScopeOfWork){
	$pdf->Cell(0,5, $ScopeOfWork, 'LR', 1, '');
}
$pdf->Cell(0,5, '', 'LBR', 1, '');

#Note
$pdf->SetFont('Times','BUI','11');
$pdf->Cell(0,5, 'Note:', 'LTR', 1, '');

$query="select note from wo where id_wo='$idwo'";
$sql = mysql_query ($query);
$note=mysql_fetch_array($sql);
$note=explode("-",$note[0]);

$pdf->SetFont('Times','BI','11');
foreach($note as $keterangan){
	$pdf->Cell(0, 5, ' - '.$keterangan, 'LR', '1', '');
}
	$pdf->Cell(0, 5, '', 'LR', '1', '');

#Service engineer incharge & approved by
$pdf->SetFont('Times','','11');
$pdf->Cell(95, 5, 'Service Engineer in-charge:','LTR');
$pdf->Cell(95, 5, 'Approved By:','LTR','1');
//########################################//
$pdf->Cell(95, 5, 'Mujiatim','LR');
$pdf->Cell(95, 5, '','LR','1');
//########################################//
$pdf->Cell(95, 20, '','LR');
$pdf->Cell(95, 20, '','LR','1');
//########################################//
$pdf->Cell(95, 15, '','LBR');
$pdf->Cell(95, 15, 'ABIDIN','LBR','1');
//########################################//
//$pdf->Cell(95, 5, '','LBR');
//$pdf->Cell(95, 5, '','LBR');

#output file PDF
$pdf->Output();
?>